package com.example.mybatisdemo.UserController;


import com.example.mybatisdemo.model.UserModel;
import com.example.mybatisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Scope("prototype")
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping(value = "/selectAll")
    public List<UserModel> selectAll() throws Exception{
        System.out.println("selectAll .... ");
        return userService.selectAll();
    }

    @PostMapping(value = "/insert")
    public int insert(@RequestParam(value = "name") String name) throws Exception{
        System.out.println("insert .... ");
        return userService.insert(name);
    }
}
